<?php
include ('../config.php');
if($input->get('do')=='chk'){
    $luser=$input->post('l_user');
    $lpass=$input->post('l_pass');
    if(empty($luser)||empty($lpass)){
        die('账号或密码不能为空！');
    }
    $sql="select * from admin WHERE auser='{$luser}' and apass='{$lpass}'";
    $Sql_result=$db->query($sql);
    $row=$Sql_result->fetch_array(MYSQLI_ASSOC);
    if(is_array($row)){
        $_SESSION['l_id']=$row['aid'];
        header('location:home.php');
    }else{
        die('张或密码不存在！');
    }
}
;?>
<!DOCTyPE HTML>
<html>
<head>
    <meta charset="utf-8"/>
    <title>管理员登录</title>
    <link rel="stylesheet" href="../public/BootStrap/css/bootstrap.min.css" />
    <script type="text/javascript" src="../public/js/jquery-3.1.1.min.js"></script>
    <script type="text/javascript" src="../public/BootStrap/js/bootstrap.min.js"></script>
</head>
<body>
    <div class="container" style="margin-top: 200px;">
        <div class="col-md-6 col-md-offset-3">
            <div class="panel panel-primary">
                <div class="panel-heading">管理员登录</div>
                <div class="panel-body">
                    <form class="form-horizontal" action="login.php?do=chk" method="post">
                        <div class="form-group">
                            <label for="inputEmail3" class="col-sm-2 control-label">用户</label>
                            <div class="col-sm-10">
                                <input type="text" name="l_user" class="form-control"  placeholder="请输入用户名">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="inputPassword3" class="col-sm-2 control-label">密码</label>
                            <div class="col-sm-10">
                                <input type="password" name="l_pass" class="form-control"  placeholder="请输入密码">
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-offset-2 col-sm-10">
                                <button type="submit" class="btn btn-default">提交登录</button>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="panel-footer text-right">所有的权版属于我</div>
            </div>
        </div>
    </div>
</body>
</html>